package cn.unknowpupil.common.core.enums;

/**
 * @Description: 健康状态 编码集 描述。</br>
 * <p>
 *      @错误级别
 *      一段
 *       - 1->业务
 *       - 2->系统
 *      二段
 *       - 001  用户系统
 *       - 000 公用
 *      三段
 *       - 001  OAuth2 模块
 *       - 002  User 模块
 *       - 100 服务熔断降级
 *       - 000 公用
 * </p>
 * @Author: <a> w10g </a>
 * @Since: 2020/6/2 13:56
 */
public enum ResultStatus {
    /* 普适码 */

    /** @系统级别*/
    SUCCESS(200, "请求成功","success"),
    FAILURE(400, "请求错误","failure"),
    FATAL_ERROR(500, "致命错误","fatal error"),




    /**@共用级别 1->01->01->01*/
    RUNTIME_ERROR(1010101, "运行时异常","runtime error"),
    PARAM_IS_INVALID(1010102, "参数异常","Parameter is invalid"),
    PARAM_IS_BLANK(1010103, "参数为空","Parameter is null"),
    PARAM_TYPE_BIND_ERROR(1010104, "参数类型错误","Parameter type error"),
    MISSING_REQUEST_PARAM_ERROR(1010105, "参数缺失","Parameters are missing"),
    POINTER_IS_NULL(1010106, "空指针异常","Null pointer exception"),
    DATABASE_ERROR(1010107, "数据异常","There is an error with the Date error"),
    NOT_FOUND(1010108, "路径不存在，请检查路径是否正确","There is an error with the not found"),
    USER_ERROR(1010109, "获取用户异常","There is an error with the not user"),



    /**@授权/令牌返回码 2->01->01->01*/
    UNAUTHORIZED(1010100, "未登录或者登录过期","Not logged in or out of date"),
    ACCOUNT_HAS_BEEN_LOGGED(2010101, "您的账号已在其他设备登录","Your account has been logged in on another device"),
    SC_UNAUTHORIZED(2010102, "访问此资源需要完全的身份验证","Full authentication is required to access this resource"),
    RESUBMIT(2010103, "您的请求太频繁，请稍后尝试！","Your requests are too frequent. Please try later"),
    USER_PASSWORD_ERROR(2010104, "用户或密码错误，请重试！","User or password error. Please try later"),
    CAPTCHA_EXIST_OR_EXPIRED(2010105, "验证码不存在或已过期","The captcha does not exist or has expired. Please try later"),
    CAPTCHA_ERROR(2010106, "验证码不存在或已过期","The captcha is error. Please try later"),

    ;


    private int code;
    private String message;
    private String interpret;

    ResultStatus(int code, String message, String interpret) {
        this.code = code;
        this.message = message;
        this.interpret = interpret;
    }

    public int code() {
        return code;
    }

    public String message() {
        return message;
    }
    public String interpret() {
        return interpret;
    }

    public boolean success() {
        return this.code == 200;
    }


/**
 * 服务异常
 *
 * 参考 https://www.kancloud.cn/onebase/ob/484204 文章
 *
 * 一共 10 位，分成四段
 *
 * 第一段，1 位，类型
 *      1 - 业务级别异常
 *      2 - 系统级别异常
 * 第二段，3 位，系统类型
 *      001 - 用户系统
 *      002 - 商品系统
 *      003 - 订单系统
 *      004 - 支付系统
 *      005 - 优惠劵系统
 *      ... - ...
 * 第三段，3 位，模块
 *      不限制规则。
 *      一般建议，每个系统里面，可能有多个模块，可以再去做分段。以用户系统为例子：
 *          001 - OAuth2 模块
 *          002 - User 模块
 *          003 - MobileCode 模块
 * 第四段，3 位，错误码
 *       不限制规则。
 *       一般建议，每个模块自增。
 */

}
